


import 'package:shared_preferences/shared_preferences.dart';

class SpUtils {
  SpUtils._privateConstructor();

  static SpUtils? _instance;

  SharedPreferences? _sharedPreferences;


  static SpUtils getInstance(){
    _instance ??= SpUtils._privateConstructor();
    return _instance!;
  }

  init() async{
    _sharedPreferences = await SharedPreferences.getInstance();
  }


  Future<void> put(String key , String value) async {
    await _sharedPreferences?.setString(key, value);
  }

  Future<String> getString(String key) async {
    String value = _sharedPreferences?.getString(key) ?? "";
    return value;
  }

  clear(){
    _sharedPreferences?.clear();
  }
}